Skip to content

Fix requestFrom() return type for 16-bit lengths #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

jrowberg
Copy link
Contributor

The latest changes to the SAMD core create a 256-byte templated ring buffer for received data in the Wire class. However, the requestFrom methods only support a uint8_t return type, which means they report 0 for the number of bytes received after a 256-byte request (I found this out the hard way). This fix changes uint8_t to size_t to match the quantity argument data type and the byteRead variable data type, which is the one actually used to provide the return value.

@sandeepmistry
Copy link
Contributor

@facchinm @cmaglie I think we should go with this, but it impacts all the cores and ArduinoCore-API: https://github.com/arduino/ArduinoCore-API/blob/master/api/HardwareI2C.h

@facchinm
Copy link
Member

It looks reasonable indeed; no code should break due to automatic promotion but we need to change the non virtual implementation in mbed and megaAVR core if we apply it to API repo.

@aentinger aentinger force-pushed the wire-requestfrom-return branch from 3f09252 to 7f8867b Compare December 10, 2020 09:43
@aentinger
Copy link
Contributor

Depends on arduino/ArduinoCore-API#132.

@aentinger aentinger merged commit 70b6a5a into arduino:master Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants